#ifndef _HELIX_TEXTURE_H_
#define _HELIX_TEXTURE_H_

#include <Math.h>
#include "../HObject.h"
#include "../Domain/HelixImage.h"


/*  class for a texture

*/

namespace helix{

	class MY_CLASS TextureParameters
	{
	private:
		unsigned char textureType;  //The type of texture to create (1d,2d,3d,cube,etc...)
		unsigned char minFilter;	//The type of filtering to use if the texture is stretched bigger than the image data
		unsigned char maxFilter;	//The type of filtering to use if the texture is stretched smaller than the image data
		unsigned char mipMapType;	//What type of mipmapping are we doing
		unsigned char uRepeat;		//How do we display a texture outside of 0->1 in the x direction
		unsigned char vRepeat;		//How do we display a texture outside of 0->1 in the y direction
		unsigned char wRepeat;		//How do we display a texture outside of 0->1 in the z direction

	public:
		static const unsigned char TEXTURE_1D = 0;			//1 dimensional texture
		static const unsigned char TEXTURE_2D = 1;			//2 dimensional texture
		static const unsigned char TEXTURE_3D = 2;			//3 dimensional texture
		static const unsigned char TEXTURE_CUBE = 3;		//Texture with 6 faces that form a cube
		static const unsigned char TEXTURE_DEPTH = 4;		//Texture with depth buffer data in it

		static const unsigned char POINT_SAMPLE_FILTERING = 0;		//Choose the nearest texel 
		static const unsigned char BILINEAR_SAMPLE_FILTERING = 1;	//perform 2 linear interpolations to find texel value
		static const unsigned char TRILINEAR_SAMPLE_FILTERING = 2;	//perform linear interpolation of 2 mipmap levels to find texel value
		
		static const unsigned char NO_MIP_MAPS = 0;					//Do not generate mipmaps automatically
		static const unsigned char AUTO_GENERATE_MIP_MAPS = 1;		//automatically generate mipmaps

		static const unsigned char REPEAT = 0;		//Repeat texture data for coordinates outside of 0->1
		static const unsigned char CLAMP = 0;		//Use border texture data for coordinates outside of 0->1

		TextureParameters(unsigned char textureType);
		~TextureParameters();

		void setTextureType(unsigned char textureType);
		void setMinFilter(unsigned char minFilter);
		void setMaxFilter(unsigned char maxFilter);
		void setMipMapType(unsigned char mipMapType);
		void setURepeat(unsigned char uRepeat);
		void setVRepeat(unsigned char vRepeat);
		void setWRepeat(unsigned char WRepeat);

		unsigned char getTextureType();
		unsigned char getMinFilter();
		unsigned char getMaxFilter();
		unsigned char getMipMapType();
		unsigned char getURepeat();
		unsigned char getVRepeat();	
		unsigned char getWRepeat();
	};


	class MY_CLASS Texture : public HObject
	{
	protected:
		unsigned int memoryFootPrint;
		bool inGraphicsMemory;

		bool isPowerOf2(unsigned int length);
		unsigned int findNextPowerOf2(unsigned int length);
	public:
		Texture(Image *image,TextureParameters *tParams);
		virtual ~Texture();

		unsigned int getMemoryFootprint();
		bool isInGraphicsMemory();
	};

}

#endif